package com.tank.netty.scoket.client;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/5/29 0029
 * Time: 上午 10:26
 * To change this template use File | Settings | File Templates.
 */
public class MyClient {

    public static void main(String[] args) {

        NioEventLoopGroup client = new NioEventLoopGroup();

        Bootstrap bootstrap = new Bootstrap();

        bootstrap.group(client);

        bootstrap.channel(NioSocketChannel.class)
                .handler(new ClientInitializer());

        try {
            ChannelFuture localhost = bootstrap.connect("localhost", 8080).sync();
            localhost.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            client.shutdownGracefully();
        }
    }
}
